"""
socket客户端开发
"""
#1.创建socket对象
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#2.连接服务器
s.connect(("127.0.0.1", 8888))
while True:
    #3.发送数据
    msg = input(">>>")
    if msg == "exit":
        break
    s.send(msg.encode("utf-8"))
    #4.接收数据 recv方法是阻塞的，直到有数据传入才返回
    data = s.recv(1024)
    print("Server:", data.decode("utf-8"))

s.close()